home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-08 | 36.9 KB | 1,050 lines | [TEXT/R*ch] |
- C.S.M.P. Digest Thu, 19 Nov 92 Volume 1 : Issue 215
-
- Today's Topics:
-
- Event Manager Too Slow or izzit just me?
- Dynamic Change of Mouse Tracking Speed
- Anyone use SoftPolish?
- DisposeHandle vs. ReleaseResource
- Forcing TextEdit to set scrpAscent and scrpHeight
- Forcing Sys6 on a Q700?
-
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- The digest is a collection of article threads from the internet newsgroup
- comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
- regularly and want an archive of the discussions. If you don't know what a
- newsgroup is, you probably don't have access to it. Ask your systems
- administrator(s) for details. You can post articles to any newsgroup by
- mailing your article to newsgroup@ucbvax.berkeley.edu. So, to post an
- article to comp.sys.mac.programmer, you mail it to
- comp-sys-mac-programmer@ucbvax.berkeley.edu. Note the '-' instead of '.'
- in the newsgroup name.
-
- Each issue of the digest contains one or more sets of articles (called
- threads), with each set corresponding to a 'discussion' of a particular
- subject. The articles are not edited; all articles included in this digest
- are in their original posted form (as received by our news server at
- cs.uoregon.edu). Article threads are not added to the digest until the last
- article added to the thread is at least one month old (this is to ensure that
- the thread is dead before adding it to the digest). Article threads that
- consist of only one message are generally not included in the digest.
-
- The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
- [128.223.8.8] in the directory /pub/mac/csmp-digest. Be sure to read the
- file /pub/mac/csmp-digest/README before downloading any files. The most
- recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
- directory /info-mac/digest/csmp. If you don't have ftp capability, the sumex
- archive has a mail server; send a message with the text '$MACarch help' (no
- quotes) to LISTSERV@ricevm1.rice.edu for more information.
-
- The digest is also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new issue as it is created. Sorry, back issues
- are not available through the mailing list.
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
-
- -------------------------------------------------------
-
- From: wwg2101@venus.tamu.edu (GILPIN, W.W.)
- Subject: Event Manager Too Slow or izzit just me?
- Organization: Texas A&M University, Academic Computing Services
- Date: Tue, 13 Oct 1992 04:49:00 GMT
-
- Here is some code from a little game thingy that I'm writing. It's part
- of the event loop I'm using for when the game is actually being played. The
- idea is that the little ship moves around on the screen and the player can
- control whether it moves up, down, left or right. From the discussion here
- I was expecting flicker problems but I haven't really experienced any of those.
- (yet...knock on wood)
-
- The problem I *am* having, though, is the movement is jumpy. I've traced
- the jumpiness to this code:
-
- while (! gameDone)
- {
- if (gWNEImplemented)
- WaitNextEvent(everyEvent, &gTheEvent, SLEEP,
- NIL_MOUSE_REGION);
- else
- {
- SystemTask();
- GetNextEvent(everyEvent, &gTheEvent);
- }
- if (gTheEvent.what == keyDown)
- gameDone = HandleGameKey(&newDirection);
- .
- .
- (move the ship and/or change directions)
- .
- .
- }
-
- Note:
- #define SLEEP 0L
- #define NIL_MOUSE_REGION 0L
-
-
- Without this code the ship moves smooth as glass...but I can't control it,
- which doesn't help. I've tried just using keyDownMask instead of everyEvent but
- that didn't help either. My questions are (1) Is there something I'm doing
- wrong or something missing that should be painfully obvious? and (2) Is there
- a faster way of getting keyboard input?
-
- If I left anything out that would make the problem easier to slove lemme
- know...
-
- Thanx
- - -------------------------------------------------------------------------------
- | Wes Gilpin | I'd kill myself for you...I'd kill you for myself |
- | WWG2101@TAMZEUS(BITNet) |------------------------------------------ |
- | WWG2101@ZEUS.TAMU.EDU | Southwest Knights of Nee Paintball Team | PANTERA |
- - -------------------------------------------------------------------------------
-
- +++++++++++++++++++++++++++
-
- Date: 13 Oct 92 09:50:12 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- > wwg2101@venus.tamu.edu (GILPIN, W.W.) writes:
-
- The problem I *am* having, though, is the movement is jumpy. I've traced
- the jumpiness to this code:
-
- if (gWNEImplemented)
- WaitNextEvent(everyEvent, &gTheEvent, SLEEP,
- NIL_MOUSE_REGION);
- else
- {
- SystemTask();
- GetNextEvent(everyEvent, &gTheEvent);
- }
-
-
- Okay, why are you checking for WaitNextEvent? Want to run
- under system 4.2 without MultiFinder? WaitNextEvent is ALWAYS
- implemented if
- 1) you run system 6.0 or higher
- or
- 2) you run MultiFInder
-
- I did away with checking a LOOOONG time ago. (Now, people, what's
- a good way of checking for MultiFinder? :-) :-) :-)
-
- if (gTheEvent.what == keyDown)
- gameDone = HandleGameKey(&newDirection);
- .
-
- You inline the event handling dispatching. That's bad style,
- because if you call WaitNextEvent some other place, or get an
- update event within a filterProc, you want to handle that event
- using your normal event handling functions.
-
- Separate out the dispatching (and use a switch for chrissake :-)
- into a HandleEvent ( EventRecord * event ) function instead.
-
- Now, about your jerkyness problem; you'll lose background tasking
- one way or the other:
-
- 1) System 6 way:
- Call GetOSEvent instead of WaitNextEvent. This will totally
- freeze up all background tasks, but will yield snappy
- performance for you. Update events and other such unimportant
- stuff won't get in your way, and clicks outside your window
- won't switch you out.
- 2) System 7 way:
- Ask the user "Would you like jerky motion and living processes,
- or should I kill the f*cking cycle-stealers ?"
- Then, if the user opts for violence, use the process manager
- to kill off all tasks except yourself. WaitNextEvent should
- be snappy enough after that.
-
- Hope this helps,
-
- - --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Suedoise (not french speaking) --
-
- There's no problem that can't be solved using brute-force algorithms
- and a sufficiently fast computer. Ergo, buy more hardware.
-
- +++++++++++++++++++++++++++
-
- From: scott@mcl.ucsb.edu (Scott Bronson)
- Date: 13 Oct 92 18:11:39 GMT
-
- In <D88-JWA.92Oct13105012@byse.nada.kth.se> d88-jwa@byse.nada.kth.se (Jon Wtte) writes:
-
- >> wwg2101@venus.tamu.edu (GILPIN, W.W.) writes:
-
- >Okay, why are you checking for WaitNextEvent? Want to run
- >under system 4.2 without MultiFinder? WaitNextEvent is ALWAYS
- >implemented if
- >1) you run system 6.0 or higher
- >or
- >2) you run MultiFInder
-
- Hey, I still check simply because it takes no time, is not hard at
- all, and I don't really like leaping off unimplemented traps if the
- user is running under an insufficient system. But, that's not the
- purpose of this followup.
-
-
- >1) System 6 way: GetOSEvent.
- >2) System 7 way: Kill all apps but me.
-
- Or, finally, a technique that works under all systems that I know
- of: don't use an event loop. Simply use GetKeys and Button to
- figure out what you want to do. This gives absolutely no time
- to anyone else, so you'll cause modem programs to overflow buffers
- and wreak all kinds of havoc, but your game will be as smooth as
- silk. I may catch flak for this for some reason, but it has worked
- for me.
-
- - Scott
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Organization: Kalamazoo College
- Date: Tue, 13 Oct 1992 19:48:21 GMT
-
- scott@mcl.ucsb.edu (Scott Bronson) writes:
- >d88-jwa@byse.nada.kth.se (Jon Wtte) writes:
- >>
- >>Okay, why are you checking for WaitNextEvent?
- >
- >Hey, I still check simply because it takes no time,
-
- You are obviously using a meaning of the word "no" with which I am
- not familiar. :-)
-
- >>1) System 6 way: GetOSEvent.
- >>2) System 7 way: Kill all apps but me.
- >
- >Or, finally, a technique that works under all systems that I know
- >of: don't use an event loop. Simply use GetKeys and Button...
-
- Allow me to provide the obligatory reminder to anyone who's going to do
- this: it's considered polite to inform the user that you're deactivating
- the rest of her computer. I suggest a notice on a splash screen or
- options screen, something like: "To obtain maximum smoothness, this
- arcade game will temporarily stop the rest of the computer. For
- example, file sharing and modem transfers will not work while the game
- is in play." (This suitably-newbie message should suffice both for games
- that don't give time, and for games that kill all other processes, I
- think.)
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "Magic Johnson says he attended two scheduled meetings [of] the president's
- AIDS commission, one more than Mr. Bush credited him with during Sunday's
- debate [and] one more than any of the three members of the Bush cabinet..."
-
- +++++++++++++++++++++++++++
-
- From: REEKES@applelink.apple.com (Jim Reekes)
- Date: 13 Oct 92 19:57:15 GMT
- Organization: Apple Computer, Inc.
-
- In article <D88-JWA.92Oct13105012@byse.nada.kth.se>,
- d88-jwa@byse.nada.kth.se (Jon Wtte) wrote:
- >
- > > wwg2101@venus.tamu.edu (GILPIN, W.W.) writes:
- >
- > The problem I *am* having, though, is the movement is jumpy. I've traced
- > the jumpiness to this code:
- >
- > if (gWNEImplemented)
- > WaitNextEvent(everyEvent, &gTheEvent, SLEEP,
- > NIL_MOUSE_REGION);
- > else
- > {
- > SystemTask();
- > GetNextEvent(everyEvent, &gTheEvent);
- > }
- >
- > [ some stuff deleted ]
- >
- > Now, about your jerkyness problem; you'll lose background tasking
- > one way or the other:
- >
- > 1) System 6 way:
- > Call GetOSEvent instead of WaitNextEvent. This will totally
- > freeze up all background tasks, but will yield snappy
- > performance for you. Update events and other such unimportant
- > stuff won't get in your way, and clicks outside your window
- > won't switch you out.
- > 2) System 7 way:
- > Ask the user "Would you like jerky motion and living processes,
- > or should I kill the f*cking cycle-stealers ?"
- > Then, if the user opts for violence, use the process manager
- > to kill off all tasks except yourself. WaitNextEvent should
- > be snappy enough after that.
-
- I'd like to point out at this time that while some developers want this,
- others are asking Apple for pre-emptive multitasking. The above would not
- be possible with a pre-emptive OS. Now, personally I'm not in favor of
- having pre-emptive OS on my personal computer. I just have to point out
- that one cannot have it both ways. The above idea is a strong argument in
- favor of not using a pre-emptive OS.
-
- - -----------------------------------------------------------------------
- Jim Reekes, Polterzeitgeist | Macintosh Toolbox Engineering
- | Sound Manager Expert
- Apple Computer, Inc. | RAll opinions expressed are mine, and do
- 20525 Mariani Ave. MS: 81-KS | not necessarily represent those of my
- Cupertino, CA 95014 | employer, Apple Computer Inc.S
-
- +++++++++++++++++++++++++++
-
- From: wwg2101@venus.tamu.edu (GILPIN, W.W.)
- Organization: Texas A&M University, Academic Computing Services
- Date: Tue, 13 Oct 1992 13:17:00 GMT
-
- >Okay, why are you checking for WaitNextEvent? Want to run
- >under system 4.2 without MultiFinder? WaitNextEvent is ALWAYS
-
- Never underestimate a business major! :) :) That's not where the slow down is
- anyway. I tried it without checking and just using WNE too.
-
- > if (gTheEvent.what == keyDown)
- > gameDone = HandleGameKey(&newDirection);
- >
- >You inline the event handling dispatching. That's bad style,
- >because if you call WaitNextEvent some other place, or get an
- >update event within a filterProc, you want to handle that event
- >using your normal event handling functions.
-
- >Separate out the dispatching (and use a switch for chrissake :-)
- >into a HandleEvent ( EventRecord * event ) function instead.
-
- Okay, I feel the need to defend myself here cause I'm not always this sloppy.
- I wrote this code quick and dirty and since right now the only thing I'm
- interested in is the 4 keydowns for the direction of the player and the 1
- other keydown for stopping the game. I just wanted to see if I could get the
- bugger to move around on the screen, dontchaknow? :) My other event loop
- for when the game ain't runnin' has a nice big switch right where it
- should be.
-
- >Now, about your jerkyness problem; you'll lose background tasking
- >one way or the other:
-
- Not a problem.
-
- >1) System 6 way:
- .
- .
- >2) System 7 way:
- .
- .
- >Hope this helps,
-
- Most definately! Thanks!
-
- - -------------------------------------------------------------------------------
- | Wes Gilpin | I'd kill myself for you...I'd kill you for myself |
- | WWG2101@TAMZEUS(BITNet) |------------------------------------------ |
- | WWG2101@ZEUS.TAMU.EDU | Southwest Knights of Nee Paintball Team | PANTERA |
- - -------------------------------------------------------------------------------
-
- +++++++++++++++++++++++++++
-
- From: de19@umail.umd.edu (Dana S Emery)
- Date: 15 Oct 92 11:15:51 GMT
- Organization: Personal
-
- In article <REEKES-131092125541@90.10.20.67>, REEKES@applelink.apple.com
- (Jim Reekes) wrote:
- >
- > In article <D88-JWA.92Oct13105012@byse.nada.kth.se>,
- > d88-jwa@byse.nada.kth.se (Jon Wtte) wrote:
- > > [ some stuff deleted ]
- > >
- > > 1) System 6 way:
- > > Call GetOSEvent instead of WaitNextEvent. This will totally
- > > freeze up all background tasks, but will yield snappy
- > > performance for you. Update events and other such unimportant
- > > stuff won't get in your way, and clicks outside your window
- > > won't switch you out.
- > > 2) System 7 way:
- > > Ask the user "Would you like jerky motion and living processes,
- > > or should I kill the f*cking cycle-stealers ?"
- > > Then, if the user opts for violence, use the process manager
- > > to kill off all tasks except yourself. WaitNextEvent should
- > > be snappy enough after that.
- >
-
- How about the Miss Manners way? check for ongoing processes, and refuse to
- torpedo the user untill the machine is clean (7), or is prounced clean (6,
- - - ). This will force the user to recognize what the machine state really
- *is*, rather than what she *thinks* it is, and will allow an orderly USER
- CONTROLLED shutdown of possibly interdependant processes.
- - --
-
- Dana S Emery <de19@umail.umd.edu> | "Novo, de Novo,
- | de novo, de no-o-o-o-o---,
- | Novemba come an' dey gonna go home."
-
- +++++++++++++++++++++++++++
-
- Date: 16 Oct 92 11:59:13 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- > de19@umail.umd.edu (Dana S Emery) writes:
-
- > > Ask the user "Would you like jerky motion and living processes,
- ~~~~~~~~~~~~
-
- *is*, rather than what she *thinks* it is, and will allow an orderly USER
- CONTROLLED shutdown of possibly interdependant processes.
-
- Maybe one could add a list of processes to the question,
- but as long as the question has a "don't kill" button,
- it's a user-in-control situatino.
-
- After all, if the user is unaware of that 400k dissertation
- in that hidden Word window, does he/she need it? :-)
-
- - --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Suedoise (not french speaking) --
- _/~| Yellow
- / * \_ Shark (This signature has won the "Worst ASCII
- ~~~~\/ Software Logo of the Year" award)
-
- ---------------------------
-
- From: ralex@tigger.cs.Colorado.EDU (Repenning Alexander)
- Subject: Dynamic Change of Mouse Tracking Speed
- Date: 13 Oct 92 19:30:09 GMT
- Organization: University of Colorado, Boulder
-
-
- I am dealing with the visual representation of complex data structures.
- I like to experiment with the Mouse Tracking Speed to make it easier
- for users to track on important information: "soft snapping".
-
- Is there some simple way to change the mouse tracking speed (e.g. via
- a trap)? What I need is a function allowing me to adjust mouse
- tracking to speeds like the ones avaivable in the MOUSE CDEV (very
- slow, .., fast). How is the MOUSE CDEV doing it?
-
- Any ideas, clues?
-
- Thanks, Alex
-
- +++++++++++++++++++++++++++
-
- From: thepope@bigboy (Michael Kohne)
- Date: 15 Oct 92 00:27:33 GMT
- Organization: Temple University
-
- ralex@tigger.cs.Colorado.EDU (Repenning Alexander) writes:
- :
- : I am dealing with the visual representation of complex data structures.
- : I like to experiment with the Mouse Tracking Speed to make it easier
- : for users to track on important information: "soft snapping".
- :
- : Is there some simple way to change the mouse tracking speed (e.g. via
- : a trap)? What I need is a function allowing me to adjust mouse
- : tracking to speeds like the ones avaivable in the MOUSE CDEV (very
- : slow, .., fast). How is the MOUSE CDEV doing it?
- :
- : Any ideas, clues?
- :
- : Thanks, Alex
-
- I don't know how to change the mouse tracking speed, but I do know that it is
- more complex than 1 number. If you can find someone with a Kensington Turbo
- Mouse, and the Turbo Mouse control panel, have them show you the 'custom'
- settings. Basically, the mouse tracking speed is a series of 8 thresholds
- that tell the system how to repond to mouse movements of varying lengths and
- speeds. I don't know where these numbers reside in memory during run-time,
- however. It may be that you could simply use macsbug to figure out what
- resource the Mouse Control panel is messing with in the system.
-
- "Pope" Q.E.D
- Michael Kohne
- thepope@bigboy.cis.temple.edu
- House of the Techno-Discordians, Archery Amusements Division
- <twang!>
-
- +++++++++++++++++++++++++++
-
- From: jmatthews@desire.wright.edu
- Date: 16 Oct 92 07:16:10 GMT
- Organization: Wright State University
-
- > ralex@tigger.cs.Colorado.EDU (Repenning Alexander) writes:
- > :
- > : I am dealing with the visual representation of complex data structures.
- > : I like to experiment with the Mouse Tracking Speed to make it easier
- > : for users to track on important information: "soft snapping".
- > :
- > : Is there some simple way to change the mouse tracking speed (e.g. via
- > : a trap)? What I need is a function allowing me to adjust mouse
- > : tracking to speeds like the ones avaivable in the MOUSE CDEV (very
- > : slow, .., fast). How is the MOUSE CDEV doing it?
- > :
- > : Any ideas, clues?
-
- Alley & Strange, _ResEdit Complete_, from the Macintosh Inside Out series,
- discusses mouse thresholds stored in 'mcky' resources. There's a nice
- explanation of what the values mean, but nothing about how to change
- them on the fly (except to edit the active system file and touch the
- control panel).
-
- I notice that booting System 5.1 messes up mouse tracking, as does the
- return to System 7 after fixing it in 5.1. I'm going to go out on a limb
- here and speculate that mouse tracking is system dependent.
-
- After many folks begged to be able to change screen depth on the fly,
- DTS produced HasDepth and SetDepth. I wonder if something analogous
- for mouse tracking might be possible.
-
- o----------------------------------------------------------------------------o
- | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
- | "Whom the gods would destroy, they first invite to program in C" |
- o----------------------------------------------------------------------------o
-
- ---------------------------
-
- From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
- Subject: Anyone use SoftPolish?
- Organization: Purdue University
- Date: Fri, 16 Oct 1992 17:46:20 GMT
-
-
-
- I've been thinking about purchasing SoftPolish, but have never
- seen any comments about it.
-
- Has anyone used it? I'd be interested in any comments, especially:
-
- 1) Is the dictionary customizable (can I add entries?)
- 2) Can you spell check only part of a resource?, I have a number
- of resources that are part text and part bitmap.
- 3) Is it generally easy to use, do you get lots of useless
- comments about your resources?
- 4) Can you specify which resource types to check (i.e. check
- some but not others?
-
- As you can see, I'm mainly interested in the spell checking part of
- it. So any comments about that aspect are especially appreciated.
-
- carl
-
-
- - --
- Carl W. Haynes III || "She'll see through me like Grandma's
- Buddy can you spare a job? || underpants."
- haynes@mace.cc.purdue.edu || -- Bart Simpson
- hcs@applelink.apple.com ||
-
-
- +++++++++++++++++++++++++++
-
- From: blob@gallant.apple.com (Brian Bechtel)
- Date: Fri, 16 Oct 1992 21:35:07 GMT
- Organization: Apple Computer Inc.
-
- haynes@mace.cc.purdue.edu (Carl W. Haynes III) writes:
-
- >I've been thinking about purchasing SoftPolish, but have never
- >seen any comments about it.
-
- >1) Is the dictionary customizable (can I add entries?)
-
- Yes.
-
- >2) Can you spell check only part of a resource?, I have a number
- > of resources that are part text and part bitmap.
-
- >3) Is it generally easy to use, do you get lots of useless
- > comments about your resources?
-
- You set the level of comments you want to receive.
-
- >4) Can you specify which resource types to check (i.e. check
- > some but not others?
-
- Yes.
-
- In general, this is a WONDERFUL product. It polishes up your grammar
- and spelling. It checks for resource validity. It checks for missing
- parts of a set of resources (e.g. DLOG without a DITL, DITL without a
- DLOG.) It does a lot more.
-
- For more information, send a message to langsys@appplelink.apple.com or
- call them at (703) 478-0181.
-
- - --Brian Bechtel blob@apple.com "My opinion, not Apple's"
-
-
- ---------------------------
-
- From: system@asuvax.eas.asu.edu (Marc Lesure)
- Subject: DisposeHandle vs. ReleaseResource
- Organization: Arizona State University
- Date: Thu, 15 Oct 1992 20:20:20 GMT
-
- I have a routine that deletes, adds, and updates a resource in a
- preference file. The function performs what it is suppose to do, however
- it doesn't seem to release the memory (if I call the routine enough times,
- it dies with a dsMemFullErr). I understand that you need to use
- ReleaseResource(), if the allocated handle came from GetResource(). But
- what if the handle is created via a NewHandle() call?
-
- Here is the snippet:
-
- writePrefs(void)
- {
- Handle aH;
- int resFile,tmpResFile;
-
- tmpResFile = CurResFile();
- resFile = openPrefs();
- UseResFile(resFile);
-
- /* delete old resource */
- aH = Get1Resource(TYPE, baseID);
- if (aH != NIL)
- {
- RmveResource(aH);
- UpdateResFile(resFile);
- ReleaseResource(aH);
- aH = NIL;
- }
-
- /* add new resource */
- if (aH == NIL)
- {
- aH = NewHandle(...);
- if (aH == NIL)
- return;
- AddResource(aH, TYPE, baseID, NAME);
- }
-
- /* update resource */
- if (ResError() == noErr)
- {
- HLock(aH);
- ... fill handle ...
- HUnlock(aH);
-
- ChangedResource(aH);
- WriteResource(aH);
- }
-
- ReleaseResource(aH); /* or DisposeHandle or Both? */
-
- UseResFile(tmpResFile);
- CloseResFile(resFile);
- }
-
- - -----------------------------------------------------------------------
- Marc Lesure / Arizona State University / Tempe, AZ
- "Between the world of men and make-believe, I can be found..."
- "False faces and meaningless chases, I travel alone..."
- "And where do you go when you come to the end of your dream?"
-
- UUCP: ...!ncar!noao!asuvax!lesure
- Internet: lesure@asuvax.eas.asu.edu
-
- +++++++++++++++++++++++++++
-
- From: marshall@sdd.hp.com (Marshall Clow)
- Date: 15 Oct 92 20:55:45 GMT
- Organization: Hewlett Packard San Diego Printer Division
-
- In article <1992Oct15.202020.17123@asuvax.eas.asu.edu>,
- system@asuvax.eas.asu.edu (Marc Lesure) wrote:
- >
- > I have a routine that deletes, adds, and updates a resource in a
- > preference file. The function performs what it is suppose to do, however
- > it doesn't seem to release the memory (if I call the routine enough times,
- > it dies with a dsMemFullErr). I understand that you need to use
- > ReleaseResource(), if the allocated handle came from GetResource(). But
- > what if the handle is created via a NewHandle() call?
- >
- > [ code deleted ]
-
- Rule of thumb: If a handle refers to a resource, then use ReleaseResource.
- If it doesn't, then use DisposHandle. It doesn't matter how it was created.
-
- DetachResource and RmveResource turn resource handles into a
- non-resource handle. AddResource turns a non-resource handle into a
- resource handle.
-
- Even bigger rule of thumb: Check for errors!!!
-
- Here lies one problem in your code:
- > RmveResource(aH);
- > UpdateResFile(resFile);
- > ReleaseResource(aH);
- ReleaseResource does nothing if aH is not a handle to a resource.
- ResError will tell you this. (See rule #2)
-
-
- Marshall Clow
- San Diego Printer Division Hewlett Packard
- Internet: marshall@sdd.hp.com AppleLink: HP.Marshall AOL: MClow
-
- +++++++++++++++++++++++++++
-
- From: thepope@bigboy (Michael Kohne)
- Date: 15 Oct 92 23:38:59 GMT
- Organization: House of the Techno-Discordians
-
-
- system@asuvax.eas.asu.edu (Marc Lesure) writes:
- : I have a routine that deletes, adds, and updates a resource in a
- : preference file. The function performs what it is suppose to do, however
- : it doesn't seem to release the memory (if I call the routine enough times,
- : it dies with a dsMemFullErr). I understand that you need to use
- : ReleaseResource(), if the allocated handle came from GetResource(). But
- : what if the handle is created via a NewHandle() call?
- :
- <Some code deleted>
- : /* add new resource */
- : if (aH == NIL)
- : {
- : aH = NewHandle(...);
- : if (aH == NIL)
- : return;
- : AddResource(aH, TYPE, baseID, NAME);
- At this point you will need to ReleaseResource. I always do a ChangedResource,
- then a WriteResource first, but the ChangedResource might not be necessary.
- : }
-
- : -----------------------------------------------------------------------
- : Marc Lesure / Arizona State University / Tempe, AZ
- : "Between the world of men and make-believe, I can be found..."
- : "False faces and meaningless chases, I travel alone..."
- : "And where do you go when you come to the end of your dream?"
- :
- : UUCP: ...!ncar!noao!asuvax!lesure
- : Internet: lesure@asuvax.eas.asu.edu
-
- Michael Kohne
- thepope@bigboy.cis.temple.edu
- House of the Techno-Discorians, Ammunition Amusements Division
- <bang!>
-
- +++++++++++++++++++++++++++
-
- From: ivanski@world.std.com (Ivan M CaveroBelaunde)
- Organization: The World Public Access UNIX, Brookline, MA
- Date: Fri, 16 Oct 1992 04:13:33 GMT
-
- system@asuvax.eas.asu.edu (Marc Lesure) writes:
-
- >I have a routine that deletes, adds, and updates a resource in a
- >preference file. The function performs what it is suppose to do, however
- >it doesn't seem to release the memory (if I call the routine enough times,
- >it dies with a dsMemFullErr). I understand that you need to use
- >ReleaseResource(), if the allocated handle came from GetResource(). But
- >what if the handle is created via a NewHandle() call?
-
- Couple of problems here. First of all, you don't need to call
- ReleaseResource if you've removed it already from your resource map.
- In fact, ReleaseResource will do nothing. Thus you need to call
- DisposHandle.
-
- Second, just to be on the safe side, you probably should SetResLoad(false)
- before getting the resource you're removing. Otherwise you might get
- NIL back from Get1Resource, not because it didn't find it, but because it
- could not be loaded into memory. If this happens, then you won't be
- able to perform the AddResource properly (in fact, you'll end up with
- two resources with the same type and ID in that file - a BAD thing).
- Don't forget to SetResLoad(true) immediately after the Get1Resource.
-
- >/* delete old resource */
- SetResLoad(false);
- > aH = Get1Resource(TYPE, baseID);
- SetResLoad(true);
- > if (aH != NIL)
- > {
- > RmveResource(aH);
- > UpdateResFile(resFile);
- DisposHandle(aH);
- /* Do even if aH points to a purged handle to free the
- master pointer. */
- /* Comment out
- > ReleaseResource(aH);
- */
- > aH = NIL;
- > }
-
- >/* add new resource */
- > if (aH == NIL)
- > {
- > aH = NewHandle(...);
- > if (aH == NIL)
- > return;
- > AddResource(aH, TYPE, baseID, NAME);
- > }
-
- You might want to build this handle before toasting the old Prefs.
- In general, I'd say it's bad form to nuke the old prefs and then be
- unable to write out the new prefs because you were unable to allocate
- space for the new prefs handle.
- >
- >/* update resource */
- > if (ResError() == noErr)
- > {
- > HLock(aH);
- > ... fill handle ...
- > HUnlock(aH);
- >
- > ChangedResource(aH);
- > WriteResource(aH);
- > }
-
- > ReleaseResource(aH); /* or DisposeHandle or Both? */
-
- Just use release resource.
-
- > UseResFile(tmpResFile);
- > CloseResFile(resFile);
-
- Your UseResFiles are a little mixed up. The only reason you'd need to do
- the tempResFile bit at top is if the prefs res file was open in the first
- place (if it's closed it'd become the current resFile when you open it,
- so there would be no need to do UseResFile). If it was already open,
- however, then you probably don't want to close it on exit.
-
- Finally, it is also possible to do the following:
- Open the prefs file
- SetResLoad(false)
- prefH = Get1Resource(prefs)
- SetResLoad(true)
- if (!prefH) {
- newlyAdded = true;
- prefH = NewHandle()
- if (!prefH) return(MemError())
- AddResource(prefH, etc)
- } else newlyAdded = false;
- LoadResource(prefH)
- if (StripAddress(*prefH)) {
- fillPrefsHandle(prefH)
- ChangedResource(prefH)
- WriteResource(prefH)
- } else {
- RemoveResource(prefH)
- DisposHandle(prefH)
- }
-
- Something like this would modify the prefs handle already in the resource
- map. It seems a little cleaner, IMHO.
-
- Hope this helps,
-
- - -Ivan
- - -----
- Ivan Cavero Belaunde (ivanski@world.std.com)
- DiVA Corporation
-
- ---------------------------
-
- From: tonym@polari.online.com
- Subject: Forcing TextEdit to set scrpAscent and scrpHeight
- Organization: Seattle Online Public Access Unix. (206) 328-4944 (all lines telebit-equipped)
- Date: Sun, 11 Oct 1992 01:32:21 GMT
-
- I am writing a Windows version of a Mac application. It uses the same file
- format as the Mac version. This file format uses style scrap records to
- store information about the text styles. So on the Windows end, I have to
- generate scrap style records myself without the help of TextEdit. The
- problem is setting the scrpHeight and scrpAscent fields properly. Since
- I have no way of obtaining font metrics, it seems like I am stuck. My
- question is this: is there some "magic" value for these fields that will
- force text edit to read the font metrics and fill them in properly? I
- tried -1, but this did not do it.
-
- If there is no magic value, I will have to modify the Mac program to
- get it to reread the font metrics if the file is coming from Windows.
- What is the easiest way to get TextEdit to do this? Interestingly
- enough, TESetSelect rereads these fields, but this seems like the
- wrong function for this purpose.
-
- If you have any answers or ideas, I would be much obliged. If you can figure
- out a method that does not require any changes on the Mac end, I will mention
- your name in the "Special Thanks To..." section of the manual! :-)
-
- - --
- Tony Mann
- Spontaneous Software
-
- +++++++++++++++++++++++++++
-
- Date: 13 Oct 92 09:53:34 GMT
- Organization: Royal Institute of Technology, Stockholm, Sweden
-
- > tonym@polari.online.com writes:
-
- I am writing a Windows version of a Mac application. It uses the same file
-
- Gee, aren't we all? :-)
-
- format as the Mac version. This file format uses style scrap records to
- store information about the text styles. So on the Windows end, I have to
-
- Sorry, but style scrap records are WHOLLY INSUITABLE for temporary
- storage, since it refers to fints by number. Font numbers change
- between machines, and even ON machines sometimes. Store font info
- by name. When you do this, you'll see that the other things you
- do will fall out naturally.
-
- You might also want to set up a mapping from windows/mac fonts; so
- the user can choose to substitute appropriate fonts from platform
- to platform.
-
- - --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Suedoise (not french speaking) --
-
- There's no problem that can't be solved using brute-force algorithms
- and a sufficiently fast computer. Ergo, buy more hardware.
-
- +++++++++++++++++++++++++++
-
- From: de19@umail.umd.edu (Dana S Emery)
- Date: 15 Oct 92 11:02:29 GMT
- Organization: Personal
-
- In article <D88-JWA.92Oct13105334@byse.nada.kth.se>,
- d88-jwa@byse.nada.kth.se (Jon Wtte) wrote:
- >
- > Sorry, but style scrap records are WHOLLY INSUITABLE for temporary
- > storage, since it refers to fints by number. Font numbers change
- > between machines, and even ON machines sometimes. Store font info
- > by name. When you do this, you'll see that the other things you
- > do will fall out naturally.
-
-
- isn't that a bit draconian? I agree that no code should depend on fond ID
- info, but I would use the style scrap record plus a font name table with
- the fond id as key, and the font baseline/ascent/descent info as well.
-
- Defering the fondID resolution to the reader seems a nicely conservative
- approach.
-
- Readout would involve a resolution of the (possibly) different id's, and
- haveing them available helps to clarify not just ID collision resolutions,
- but also diferent font/same name/different ID confusions. (Too bad so many
- utilitys "protect" the user from such "confusing" information.) I would
- compare the fontname saved to the fontname available for the saved ID, and
- ask the user for a substitute when things dont check out. Noisy? yes, but
- I (as a user) like things that way.
-
- 's too bad that TE doesn't handle -1 in those fields, I was hopeing for
- that to be true for a presently backburnured project. :-(
-
- - --
-
- Dana S Emery <de19@umail.umd.edu> | "Novo, de Novo,
- | de novo, de no-o-o-o-o---,
- | Novemba come an' dey gonna go home."
-
- ---------------------------
-
- From: kjh+@cs.cmu.edu (Kenneth Hughes)
- Subject: Forcing Sys6 on a Q700?
- Date: 14 Oct 92 04:53:58 GMT
- Organization: School of Computer Science, Carnegie Mellon
-
- Anyone know the inside technical details as to why a Q700 (or any other
- System-7-only platform) cannot run System 6.0.x ? I'm wondering how feasible
- it'd be to hack something up so that I can test and debug some code under
- System 6 without having to pick up another Mac besides my Q700.
-
- Along those lines, does anyone know the current break-down of System 7 vs
- System 6 users? Has it passed 50/50 yet? Thanks for any info.
-
- Kenneth J. Hughes (kjh@cs.cmu.edu)
-
- +++++++++++++++++++++++++++
-
- From: bredell@tdb.uu.se (Mats Bredell)
- Organization: Uppsala University Computing Center (UDAC)
- Date: Thu, 15 Oct 1992 08:12:27 GMT
-
- Kenneth Hughes (kjh+@cs.cmu.edu) wrote:
- : Anyone know the inside technical details as to why a Q700 (or any other
- : System-7-only platform) cannot run System 6.0.x ? I'm wondering how feasible
- : it'd be to hack something up so that I can test and debug some code under
- : System 6 without having to pick up another Mac besides my Q700.
- :
- : Along those lines, does anyone know the current break-down of System 7 vs
- : System 6 users? Has it passed 50/50 yet? Thanks for any info.
-
- There's a version of system 6 that works on the PowerBooks. I think this also
- works on the Quadras. The version is called 6.0.8L.
-
- /Mats
- - --
- Mats Bredell Mats.Bredell@udac.uu.se
- Uppsala University Computing Center (UDAC) Ph: +46 18 187817
- Department of medical systems Fax: +46 18 187825
- Sweden Think straight - be gay!
-
- +++++++++++++++++++++++++++
-
- From: kjh+@cs.cmu.edu (Kenneth Hughes)
- Date: 15 Oct 92 20:10:25 GMT
- Organization: School of Computer Science, Carnegie Mellon
-
- Here's a summary of the responses I received on this topic:
-
- Since 7.0.1 has ROM bug fixes for the Quadras (that of course are missing
- in System 6 since the Quadra's came out after the last version of System 6
- had been released), it would not really be feasible to attempt to hack
- something to make System 6 run on the Quadras.
-
- Mats.Bredell@udac.uu.se wrote:
- > There's a version of system 6 that works on the PowerBooks. I think this also
- > works on the Quadras. The version is called 6.0.8L.
-
- According the the 10-5-92 article in MacWEEK:
- "The new-found system is labeld 6.0.8L. It supports a limiteed set of Macs:
- the PowerBook 100, the LC, LC II, Classic and Classic II. Other models, such
- as the Mac II, IIcx and IIci, are not supported at all."
- I didn't see anywhere else any mention of Quadra support. If it's in
- there (which I doubt) I'd love to hear about it.
- They do later refer to an "acute " desire for System 6, however.
- This in fact had prompted my other question regarding what fraction of users
- still use System 6. I didn't get any numbers on this, but one respondent
- pointed out that he thought the System 6 hold-outs were probably much less
- likely to be buying software. I'd love to get some real numbers on this if
- any developer has any info to share.
- Thanks especially to Jon W{tte and Larry Rosenstein for their comments.
-
- Kenneth J. Hughes (kjh@cs.cmu.edu)
- Entelechy Corporation
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Date: 15 Oct 92 21:24:31 GMT
- Organization: Kalamazoo College
-
- kjh+@cs.cmu.edu (Kenneth Hughes) writes:
- >
- >...one respondent
- >pointed out that he thought the System 6 hold-outs were probably much less
- >likely to be buying software. I'd love to get some real numbers on this if
- >any developer has any info to share.
-
- No numbers, but the other day I did see a bumper sticker that read
- "I'm pro-System-6...and I purchase!"
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- I suppose ya don't think I was run over by a streetcar!
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-